#include "array.hpp"

ArrayInt::ArrayInt(){
	size = 0;
	data = NULL;
}

ArrayInt::ArrayInt(const size_t n){
	size = n;
	data = (size) ? new int[size] : NULL;
}

ArrayInt::~ArrayInt(){
	delete[] data;
}

ArrayInt::ArrayInt(const ArrayInt &A){
	size = A.size;
	if(size){
		data = new int[size];
		for(size_t i = 0; i < size; ++i)
			data[i] = A.data[i];
	} else {
		data = NULL;
	}
}

const ArrayInt& ArrayInt::operator=(const ArrayInt &rhs){
	if(this != &rhs){
		delete[] data;
		size = rhs.size;
		if(size){
			data = new int[size];
			for(size_t i = 0; i < size; ++i)
				data[i] = rhs.data[i];
		} else {
			data = NULL;
		}
	}
	return *this;
} 

int& ArrayInt::operator[](const size_t indx){ 
	return data[indx];
}

const int& ArrayInt::operator[] (const size_t indx) const {
	return data[indx];
}

size_t ArrayInt::length() const {
	return size;
}

